#include <cstdio>
#include <algorithm>

using namespace std;

struct Node
{
    int p, q, v;
};

bool operator < ( const Node &a, const Node &b )
{
    return a.q - a.p < b.q - b.p;
}

Node a[ 501 ];
int f[ 5001 ], n, m;

void init( )
{
    int i;
    for ( i = 0; i < n; i++ )
        scanf("%d%d%d" ,&a[ i ].p, &a[ i ].q, &a[ i ].v);
    sort( a, a + n );
    for ( i = 0; i <= m; i++ )
        f[ i ] = 0;
}

void work( )
{
    int i, j, ans = 0;
    for ( i = 0; i < n; i++ )
        for ( j = m; j >= a[ i ].p && j >= a[ i ].q; j-- )
            if ( f[ j - a[ i ].p ] != -1 && f[ j ] < f[ j - a[ i ].p ] + a[ i ].v )
                f[ j ] = f[ j - a[ i ].p ] + a[ i ].v;
    for ( i = 0; i <= m; i++ )
        if ( ans < f[ i ] )
            ans = f[ i ];
    printf("%d\n", ans);
}

int main( )
{
    while ( scanf("%d%d", &n, &m) != EOF )
    {
        init( );
        work( );
    }
    return 0;
}
